<?php
require_once('class.weather.php');
class GoogleWeather extends Weather {
	public function __construct() {}

	public function read($city)
	{
		$this->city = $city;
		$xmlString = file_get_contents('http://www.google.com/ig/api?hl=ko&weather='.$this->city.'&oe=UTF-8');
		$this->xml = new SimpleXMLElement($xmlString);
		$this->ok = $this->parse();
		return ;
	}
	
	private function parse()
	{
		if(empty($this->xml) || !empty($this->xml->weather->problem_cause['data']))
			return false;
		$this->forcast_date = $this->xml->weather->forecast_information->forcast_date['data'];
		$this->current_date_time = $this->xml->weather->forecast_information->current_date_time['data'];
		$this->current_conditions = $this->xml->weather->current_conditions;
		foreach($this->xml->weather->forecast_conditions as $item)
			$this->forecast_conditions[] = $item;
		return true;
	}
}
?>